import request from '@/utils/request'
import { AxiosPromise } from 'axios'
/**
 * 章节内容api
 */

const getSectionAndLesson = (courseId: number|string): AxiosPromise<any> => {
  return request({
    method: 'GET',
    url: '/boss/course/section/getSectionAndLesson',
    params: {
      courseId
    }
  })
}

export interface CreateOrUpdateSectionType {
    id?: number | null
    courseId?: number | string | null
    courseName?: string
    sectionName?: string
    description?: string
    orderNum?: number
    status?: number
}

const createOrUpdateSection = (data: CreateOrUpdateSectionType): AxiosPromise<any> => {
  return request({
    method: 'POST',
    url: '/boss/course/section/saveOrUpdateSection',
    data
  })
}

const getSectionById = (sectionId: number): AxiosPromise<any> => {
  return request({
    method: 'GET',
    url: '/boss/course/section/getBySectionId',
    params: {
      sectionId
    }
  })
}

export {
  getSectionAndLesson,
  createOrUpdateSection,
  getSectionById
}
